<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>签到管理</title>
	<link rel="stylesheet" href="../css/common2.css">
	<link rel="stylesheet" href="../css/urlty.css">
	<style>
		.state {
			color: white;
			border-radius: 3px;
			font-size: 14px;
			font-weight: bold;
			letter-spacing: 3px;
			padding: 5px 8px;
			background-color: #4BAF4F;
		}

		.conduct {
			background-color: #F8B551;
		}

		.end {
			background-color: #E64919;
		}

		.class-end {
			background-color: #9F9F9F;
		}

		html {
			position: relative;
		}

		#vue-root {
			padding-top: 20px;
		}

		.search_img {
			position: absolute;
			right: 3%;
		}

		.search {
			max-width: 120px;
			height: 33px;
			position: absolute;
			right: calc(2% + 60px + 147px);
		}

		.search-course {
			right: calc(2% + 60px);
		}

		.export {
			margin-left: 10px;
		}

		.date {
			width: 65px;
			font-size: 12px;
			position: absolute;
			padding-left: 5px;
			height: 33px;
			border: 1px solid;
		}
	</style>
</head>

<body>
	<div id="vue-root">
		<div class="refresh" onclick="location.reload()">刷新</div>
		<input placeholder="请输入签到人" class="search" v-model="search.studentName">
		<select class="search search-course" v-model="search.lessonId">
			<option :value="undefined">请选择课程</option>
			<option v-for="lesson in lessons" :key="lesson.id" :value="lesson.id" v-text="lesson.name">
			</option>
		</select>

		<input placeholder="开始时间" v-model="search.startTime" class="date" id="startTime" style="right: 470px;">
		<input placeholder="结束时间" v-model="search.endTime" class="date" id="endTime"
			style="right: 400px;border-left: none;">

		<img src="../image/search.png" @click="getData0" height="35" width="35" alt="" class="search_img">
		<div class="table">
			<table class="table_top" id="table-header">
				<thead>
					<tr>
						<th class="one">
							<input type="checkbox" class="check-box" v-model="all">序号
						</th>
						<th>签到人</th>
						<th>签到课程</th>
						<th>签到课时</th>
						<th>签到时间</th>
						<th>删除</th>
					</tr>
				</thead>
				<tbody id="table-list">
					<tr v-for="(punch,index) in list" :key="punch.id">
						<td class="one">
							<input type="checkbox" class="check-box" v-model="all">
							<span v-text="index+1"></span>
						</td>
						<td v-text="punch.studentName"></td>
						<td v-text="punch.lessonName"></td>
						<td>第{{punch.seq}}课时</td>
						<td v-text="format(punch.time)"></td>
						<td>
							<div>
								<!--class="option"-->
								<div class="edit-icon option-icon" @click="del([punch.id])">
									<!--style="margin-left: calc((100% - 35px)/2);"-->
									<img class="img" src="../image/delete.png" height="20" width="20"
										onmouseover="this.src='../image/delete_light.png'"
										onmouseout="this.src='../image/delete.png'">
								</div>
							</div>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		<div class="delete" @click="batchDelete" v-if="total>1">批量删除</div>
		<div class="delete export" @click="exports">批量导出</div>
		<ul class="pagination" v-if="pages>1">
			<li>
				<a v-if="pageNum!=1" @click="pageNum=1">«</a>
				<a class="pages-jump" v-if="pageNum!=1" @click="pageNum--">‹</a>
				<a v-text="pageNum"></a>
				<a class="pages-jump" v-if="pageNum!=pages" @click="pageNum++">›</a>
				<a v-if="pageNum!=pages" @click="pageNum=pages">»</a>
			</li>
		</ul>
	</div>

	<script src="/scriptZIP/qs.min.js"></script>
	<script src="/scriptZIP/vue.min.js"></script>
	<script src="/scriptZIP/axios.min.js"></script>

	<script src="/scriptZIP/dayjs.min.js"></script>

	<script src="/scriptZIP/dayjs.min.js"></script>


	<script src="/lib/laydate/laydate.js"></script>

	<script src="/js/common.js"></script>
	<script src="/js/list.js"></script>

	<script>

		var schoolId = top_params().id;

		var app = new Vue(merge({
			data: {
				lessons: [],
				urls: {
					del: '/pc/lesson_punch/del',
					list: '/pc/lesson_punch/list/' + schoolId
				}
			},
			created: function () {
				this.getData();
				axios.get('/pc/lesson/all/' + schoolId).then(function (res) {
					this.lessons = res.data;
				}.bind(this));
			},
			methods: {
				format: function (time) {
					if (!time) return null;
					return dayjs(time).format('YYYY-MM-DD HH:mm:ss');
				},
				exports: function () {
					var q = Qs.stringify(this.search);
					if (q) q = '?' + q;
					location.href = '/pc/lesson_punch/export/' + schoolId + q;
				},
			}
		}));

		laydate.render({
			elem: '#startTime',
			type: 'datetime',
			done: function (value, date, endDate) {
				app.search.startTime = value;
			}
		});

		laydate.render({
			elem: '#endTime',
			type: 'datetime',
			done: function (value, date, endDate) {
				app.search.endTime = value;
			}
		});
	</script>

</body>

</html>